package com.sc.nft.entity.vo;

import cn.hutool.core.collection.CollUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

@Data
public class QueryBoxConditionPackagingVO {


    @ApiModelProperty(value = "盲盒nft持有配置")
    private QueryBoxConditionCollectionVO queryBoxConditionCollection;

    @ApiModelProperty(value = "兑换配置")
    private List<QueryBoxConditionVO> queryBoxCondition;

    @ApiModelProperty("品牌id")
    private Long daoId;

    @ApiModelProperty("品牌名称")
    private String daoName;

    public void transition() {
        // 把queryBoxCondition 兑换配置中的type为1的数据,转换为queryBoxConditionCollection 盲盒nft持有配置
        List<QueryBoxConditionVO> collect = queryBoxCondition.stream().filter(queryBoxConditionVO -> queryBoxConditionVO.getType().equals(1)).collect(Collectors.toList());
        this.queryBoxCondition = queryBoxCondition.stream().filter(queryBoxConditionVO -> !queryBoxConditionVO.getType().equals(1)).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(collect)) {
            QueryBoxConditionVO queryBoxConditionVO = collect.get(0);
            QueryBoxConditionCollectionVO queryBoxConditionCollectionVO = new QueryBoxConditionCollectionVO();
            queryBoxConditionCollectionVO.setName(queryBoxConditionVO.getName());
            queryBoxConditionCollectionVO.setTripartiteId(queryBoxConditionVO.getTripartiteId());
            queryBoxConditionCollectionVO.setProductBoxId(queryBoxConditionVO.getProductBoxId());
            this.queryBoxConditionCollection = queryBoxConditionCollectionVO;
        }

    }
}
